package fengstyle.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import fengstyle.po.TOrder;
import fengstyle.repository.OrderRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

@Service
public class OrderServiceImpl implements OrderService{

    @Resource
    private OrderRepository orderRepository;

    @Override
    public void add(TOrder order) {
        orderRepository.insert(order);
    }

    @Override
    public List<TOrder> getList(String startDate, String endDate) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        QueryWrapper<TOrder> wrapper = new QueryWrapper<>();
        wrapper.ge("change_date", startDate)
                .le("change_date", endDate);
        return orderRepository.selectList(wrapper);
    }
}
